package stream._01;

import java.util.ArrayList;
import java.util.List;

public class App {

	public static void main(String[] args) {
		List<Apple> list = getApple();
		list.stream()
			.filter(a -> a.getWeight() == 100)
			.map(a -> {
				a.setWeight(a.getWeight() + 50);
				return a;
			})
			.sorted((a, b) -> a.getColor().length() - b.getColor().length())
			.forEach(System.out::println);
	}

	private static List<Apple> getApple() {
		List<Apple> list = new ArrayList<Apple>();
		list.add(new Apple("blue", 100));
		list.add(new Apple("red", 100));
		list.add(new Apple("red", 200));
		list.add(new Apple("green", 100));
		list.add(new Apple("green", 200));
		return list;
	}

}

class Apple {
	private String color;
	private Integer weight;

	public String getColor() {
		return color;
	}

	public void setColor(String color) {
		this.color = color;
	}

	public Apple(String color, Integer weight) {
		super();
		this.color = color;
		this.weight = weight;
	}

	public Integer getWeight() {
		return weight;
	}

	public void setWeight(Integer weight) {
		this.weight = weight;
	}

	@Override
	public String toString() {
		return "Apple [color=" + color + ", weight=" + weight + "]";
	}

}
